package com.tbit.uqbike.client.constant;

import com.tbit.uqbike.client.util.LogUtil;
import lombok.extern.slf4j.Slf4j;

import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

/**
 * @Author: chen
 * @Description: 备注国际化
 * @Date: 创建于 9:46 2021/3/24
 */
@Slf4j
public class LocalData {

    public static Map<String, String> localeMap = new HashMap<>();
    /**
     * 英文
     */
    public static String EN = "en";
    /**
     * 中文
     */
    public static String CN = "cn";
    /**
     * 泰语
     */
    public static String TH = "th";

    static {
        Properties props = new Properties();
        try {
            props.load(new InputStreamReader(RabbitMQData.class.getClassLoader().getResourceAsStream("locale.properties"), "UTF-8"));
            Set<String> set = props.stringPropertyNames();
            for (String tmp : set) {
                localeMap.put(tmp, props.getProperty(tmp));
            }
        } catch (Exception e) {
            LogUtil.warn("加载系统支付配置文件失败");
        }
    }

    public static void main(String[] args) throws InterruptedException {
        String lang = "cn";
        Thread t1 = new Thread(() -> {
            String tmp1 = LocalData.localeMap.get("remark16_" + lang);
            System.out.println(String.format(tmp1, 2));
        });

        Thread t2 = new Thread(() -> {
            String tmp1 = LocalData.localeMap.get("remark16_" + lang);
            System.out.println(String.format(tmp1, 2));
        });


        Thread t3 = new Thread(() -> {
            String tmp1 = LocalData.localeMap.get("remark16_" + lang);
            System.out.println(String.format(tmp1, 2));
        });

        t1.start();
        t2.start();
        t3.start();

        try {
            t1.join();
            t2.join();
            t3.join();
        } catch (InterruptedException e) {
            log.error(e.getMessage(), e);
        }
        System.out.println("线程执行完毕");

    }
}
